//
// Created by gogoqiu on 2022/2/11.
//

#ifndef RAPIDSVN_CMAKE_PREFERENCE_H
#define RAPIDSVN_CMAKE_PREFERENCEVIEW_H

#include "PreferenceStorage.h"

//???
enum PreferenceViewType{
    PT_INPUT = 0, PT_SWITCH, PT_LIST
};

/**
 * PreferenceView,
 * 存储模式
 * 往下滚动，延长
 */
class PreferenceView :public PreferenceItem{
protected:
    //
    PreferenceViewType type;
    wxString title;
    int id;
    wxWindowBase * control;
public:
    //数据改了，可以通过消息传送给app
    PreferenceView(const wxString &key, const wxString &value,
                   const wxString &defaultValue, PreferenceViewType type,
                   const wxString& title )
            : PreferenceItem(key, value, defaultValue) {
        this->type = type;
        this->title = title;
    }

    PreferenceView(PreferenceItem item, PreferenceViewType type, const wxString& title )
            : PreferenceItem( std::move(item) ) {
        this->type = type;
        this->title = title;
    }

    PreferenceView(PreferenceItem *item, PreferenceViewType type, const wxString& title ):
            PreferenceItem( item->key, item->value, item->defaultValue ) {
        //this->value = item->key;
        this->type = type;
        this->title = title;
    }

    PreferenceViewType getType(){
        return type;
    }

    wxString getTitle(){
        return title;
    }

    /*
    int getId(){
        return id;
    }

    wxTextCtrl *textCtrl;
    wxTextCtrl *valueCtrl;
    //
    wxBoxSizer* buildView( wxWindow *parent ){

        wxBoxSizer* listItemSizer = new wxBoxSizer(wxVERTICAL);
        //Connect(ID_BUTTON1,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&wxtestDialog::OnAbout);
        textCtrl = new wxTextCtrl( parent,  id, this->title, wxDefaultPosition, wxDefaultSize,
                                   0, wxDefaultValidator, _T("ID_TEXTCTRL1"));
        valueCtrl = new wxTextCtrl( parent,  id, this->title, wxDefaultPosition, wxDefaultSize,
                                    0, wxDefaultValidator, _T("ID_TEXTCTRL1"));
        listItemSizer->Add( textCtrl );
        listItemSizer->Add( valueCtrl );
        return listItemSizer;
    }*/
    //virtual wxBoxSizer* buildView( wxWindow *parent ) = 0;
    void setControl(wxWindowBase * _control){
        this->control = _control;
    }

    wxWindowBase * getControl(){
        return control;
    }
};


#endif //RAPIDSVN_CMAKE_PREFERENCE_H
